$(function(){	
	$('#register_username').blur(function(){
		var length = $(this).val().length;
		if(length < Config.usernameMinLength){
			popupMsg($(this), 'Your name is too short.');
			$(this).select();
		}else if(length > Config.usernameMaxLength){
			$(this).val($(this).val().substr(0, Config.usernameMaxLength));
			popupMsg($(this), 'Your name is too long.');
		}else{
			popupMsg();
		}
	});
	
	$('#register_email').blur(function(){
		var email_regexp = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
		var email = $(this).val();
		if(!email.match(email_regexp)){
			popupMsg($(this), 'Invalid email address.');
		}else{
			popupMsg();
		}
	});
	
	$('#register_confirm_password').blur(function(){
		if($(this).val() != $('#register_password').val()){
			popupMsg($(this), 'It\'s different from your previous password.');
		}else{
			popupMsg();
		}
	});
});